/*
 *所有关于new_overtimeline类的业务代码应在此处编写
*可使用repository.调用常用方法，获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*new_overtimelineService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VOL.Core.BaseProvider;
using VOL.Core.Extensions.AutofacManager;
using VOL.Entity.DomainModels;
using System.Linq;
using VOL.Core.Utilities;
using System.Linq.Expressions;
using VOL.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VOL.Test.IRepositories;
using Microsoft.EntityFrameworkCore.Metadata.Internal;

namespace VOL.Test.Services
{
    public partial class new_overtimelineService
    {
        private readonly IHttpContextAccessor _httpContextAccessor;
        private readonly Inew_overtimelineRepository _repository;//访问明细数据库
        private readonly Inew_overtimeRepository _overtimerepository;//访问主表数据库


        [ActivatorUtilitiesConstructor]
        public new_overtimelineService(
            Inew_overtimelineRepository dbRepository,
            Inew_overtimeRepository dbOvertimeRepository,
            IHttpContextAccessor httpContextAccessor
            )
        : base(dbRepository)
        {
            _httpContextAccessor = httpContextAccessor;
            _repository = dbRepository;
            _overtimerepository = dbOvertimeRepository;
            //多租户会用到这init代码，其他情况可以不用
            //base.Init(dbRepository);
        }

        //2.在生成页面新建数据时生成自增单据号
        //重写[表Service.cs]的add方法，实现下面的代码
        //public override WebResponseContent Add(SaveModel saveDataModel)
        //{
        //    saveDataModel.MainData["OrderNo"] = "OT";
        //    WebResponseContent webResponse = new WebResponseContent();
        //    AddOnExecuting = (new_overtimeline line, object list) =>
        //    {
        //        /************每天从1开始生成自增单据号，参数说明**********/
        //        // x => x.OrderNo 给指定字段生成单据号
        //        // "PO" 自定义单据号开头
        //        // x => x.CreateDate 指定日期字段,内部通过此字段排序，每天单据号从1开始
        //        line.new_name = line.Create(x => x.new_name, "PO", x => x.CreateDate);
        //        //var new_overtime_name = line.new_overtime_name;
        //        //string new_oertime_id = _overtimerepository.Find(x => x.new_name == new_overtime_name).Select(s => s.id).FirstOrDefault().ToString();
        //        // line.new_overtime_id = new_oertime_id;
        //        //var new_overtime_id = repository.Find<>
        //        return webResponse.OK();
        //    };
        //    return base.Add(saveDataModel);
        //}

        public override WebResponseContent Import(List<IFormFile> files)
        {

            return base.Import(files);
        }
    }
}
